require(['./config'], () => {
    require(['header', 'footer', 'jquery', 'cookie'], (header) => {
        class Login {
            constructor () {
                this.login()
            }
            // 登录
            login () {
                console.log($('#log-btn'))
                $('#log-btn').on('click', function (e) {
                    let email = $('#email1').val()
                    let password = $('#password1').val()
                    let arr = $.cookie('name')
                    this.change = true
                    console.log(arr)
                    if(arr) {
                        arr = JSON.parse(arr)
                        console.log(123)
                        arr.forEach(item => {
                            if(item.emai == emai && item.password == password){
                                alert('登录成功')
                                this.change = false
                                // location.href = '/html/index.html'
                                $.cookie('after', email, {expires:7, path:'/'})
                            }
                        })
                        if(this.change === true){
                            alert('邮箱或密码错误')
                        }
                    } else{
                        alert('请先注册')
                    }
                    e.preventDefault()
                })
            }
        }
    })
})